﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using wne.core;
//using wne.models;
//using wne.core.Interface;

//namespace wne.Tests
//{
//    [TestClass]
//    public class Class1TestChangeDb
//    {
//        [TestMethod]
//        public void DeleteGroupByIdWithoutChild_5_1()
//        {
//            core.Class1.DeleteGroupByIdWithoutChild(1002);
//            Assert.IsNull(core.Class1.GetGroupById(1002), "Группа не удалена!");
//        }

//        [TestMethod]
//        public void DeleteGroupByIdWithoutChild_not_exists_5_2()
//        {
//            bool a;
//            a = core.Class1.DeleteGroupByIdWithoutChild(2545);
//            Assert.IsFalse(a, "Группа существует!");

//        }
//        [TestMethod]
//        public void GetAllGroups_empty_4_6()
//        {
//            string warn = "incorrect result";
//            List<models.GroupSmallModel> list1 = wne.core.Class1.GetAllGroups(1);
//            Assert.IsNull(list1, warn);
//        }
//        [TestMethod]
//        public void UpdateOrAddGroup_first_NULL_6_1()
//        {
//            string warn = "incorrect result";

//            core.Class1.UpdateOrAddGroup(null, "test", "1001,1002", "fieldTest1,fieldTest2", 
//                "21,12", "true,false", "false,true", "gdg,dgd");
            
//            List<models.GroupSmallModel> list1 = wne.core.Class1.GetAllGroups(1);
//            models.GroupSmallModel group1 = new GroupSmallModel();
//            List<models.FieldModel> ListOfFields1 = new List<FieldModel>();
//            models.FieldModel field1 = new models.GroupFieldModel();
//            models.FieldModel field2 = new models.FieldModel();

//            models.FieldType fieldType1 = new models.FieldType();
//            models.FieldType fieldType2 = new models.FieldType();
            
//            group1 = list1[3];
//            ListOfFields1 = group1.Fields;
//            field1 = ListOfFields1[0];
//            field2 = ListOfFields1[1];
//            fieldType1 = field1.Type;
//            fieldType2 = field2.Type;

//            Dictionary<int, string> a = new Dictionary<int, string>();
//            models.GroupModel groupTest = wne.core.Class1.GetGroupById(group1.Id);
//            a = groupTest.AvaliableParents;

//            Assert.IsTrue(
//                group1.Name == "test" && 
//                field1.Name == "fieldTest1" && field2.Name == "fieldTest2" &&
//                fieldType1.id == 21 && fieldType2.id == 12 && 
//                field1.Value == "gdg" && field2.Value == "dgd" &&
//                field1.UserCanEdit == true && field2.UserCanEdit == false && 
//                field1.mandatory == false && field2.mandatory == true && 
//                a.ContainsKey(1001) && a.ContainsKey(1002)
//            , warn);
//        }

//        [TestMethod]
//        public void UpdateOrAddGroup_6_2()
//        {
//            string warn = "incorrect result";

//            core.Class1.UpdateOrAddGroup("1000", "test", "1001,1002", "fieldTest1,fieldTest2,fieldTest3",
//                "21,12,22", "true,false,true", "false,true,false", "gdg,dgd,ddd");

//            List<models.GroupSmallModel> list1 = wne.core.Class1.GetAllGroups(1);
//            models.GroupSmallModel group1 = new GroupSmallModel();
//            List<models.FieldModel> ListOfFields1 = new List<FieldModel>();
//            models.FieldModel field1 = new models.FieldModel();
//            models.FieldModel field2 = new models.FieldModel();
//            models.FieldModel field3 = new models.FieldModel();

//            models.FieldType fieldType1 = new models.FieldType();
//            models.FieldType fieldType2 = new models.FieldType();
//            models.FieldType fieldType3 = new models.FieldType();

//            group1 = list1[3];
//            ListOfFields1 = group1.Fields;
//            field1 = ListOfFields1[0];
//            field2 = ListOfFields1[1];
//            field3 = ListOfFields1[2];

//            fieldType1 = field1.Type;
//            fieldType2 = field2.Type;
//            fieldType3 = field3.Type;

//            Dictionary<int, string> a = new Dictionary<int, string>();
//            models.GroupModel groupTest = wne.core.Class1.GetGroupById(group1.Id);
//            a = groupTest.AvaliableParents;

//            Assert.IsTrue(
//                group1.Name == "test" &&
//                field1.Name == "fieldTest1" && field2.Name == "fieldTest2" && field3.Name == "fieldTest3" &&
//                fieldType1.id == 21 && fieldType2.id == 12 && fieldType3.id == 22 &&
//                field1.Value == "gdg" && field2.Value == "dgd" && field3.Value == "ddd" &&
//                field1.UserCanEdit == true && field2.UserCanEdit == false && field3.UserCanEdit == true &&
//                field1.mandatory == false && field2.mandatory == true && field3.mandatory == false &&
//                a.ContainsKey(1001) && a.ContainsKey(1002)
//            , warn);

//        }
//        [TestMethod]
//        public void UpdateOrAddGroup_parent_group_6_6()
//        {
//            string warn = "incorrect result";

//            core.Class1.UpdateOrAddGroup(null, "test", "1001,1001,1001,1002,1002", "fieldTest1,fieldTest2",
//                "21,12", "true,false", "false,true", "gdg,dgd");

//            List<models.GroupSmallModel> list1 = wne.core.Class1.GetAllGroups(1);
//            models.GroupSmallModel group1 = new GroupSmallModel();
//            List<models.FieldModel> ListOfFields1 = new List<FieldModel>();
//            models.FieldModel field1 = new models.FieldModel();
//            models.FieldModel field2 = new models.FieldModel();

//            models.FieldType fieldType1 = new models.FieldType();
//            models.FieldType fieldType2 = new models.FieldType();

//            group1 = list1[3];
//            ListOfFields1 = group1.Fields;
//            field1 = ListOfFields1[0];
//            field2 = ListOfFields1[1];
//            fieldType1 = field1.Type;
//            fieldType2 = field2.Type;

//            Dictionary<int, string> a = new Dictionary<int, string>();
//            models.GroupModel groupTest = wne.core.Class1.GetGroupById(group1.Id);
//            a = groupTest.AvaliableParents;

//            Assert.IsTrue(
//                a.ContainsKey(1001) && a.ContainsKey(1002) && a.Count == 2
//            , warn);
            
//        }

//        [TestMethod]
//        public void UpdateOrAddUser_true_8_1()
//        {
//            string sss, warn = "incorrect result";

//            models.EditUser test1 = new EditUser();
//            test1.Id = 1001;
//            test1.User_Name = "test";
//            test1.User_Email = "test@mail.ru";
//            test1.User_BD = "01.10.2000";
            
//            List<IntString> Groups1 = new List<IntString>();
//            IntString is1 = new IntString();
//            is1.i = 1002;
//            is1.s = "Other";
//            Groups1.Add(is1);
//            test1.Groups = Groups1;

//            List<Group_Field> User_Fields1 = new List<Group_Field>();
//            Group_Field group_field1 = new Group_Field();
//            group_field1.Id = 1002;
//            group_field1.Name = "Other";
//            List<FieldModel> fields1 = new List<FieldModel>();
//            FieldModel field1 = new FieldModel();

//            field1.Name = "h";
//            FieldType type1 = new FieldType();
            

//            type1.id = 1;
//            field1.Value = "yyy";
//            field1.UserCanEdit = true;
//            field1.mandatory = true;
            
//            fields1.Add(field1);

//            group_field1.Fields = fields1;
//            User_Fields1.Add(group_field1);
//            test1.User_Fields = User_Fields1;

//            Dictionary<int, string> allgroupsTest = new Dictionary<int, string>();
//            allgroupsTest.Add(1000, "All Users");
//            allgroupsTest.Add(1001, "Admins");

//            test1.AllGroups = allgroupsTest;

//            UpdateOrAddUser(test1);
            
//            test1 = GetUserById(1001);

//            allgroupsTest = test1.AllGroups;

//            User_Fields1 = test1.User_Fields;
//            group_field1 = User_Fields1[0];
//            fields1 = group_field1.Fields;
//            field1 = fields1[0];

//            Groups1 = test1.Groups;
//            is1 = Groups1[0];

//            Assert.IsTrue(
//                test1.Id == 1001 && test1.User_Name == "test" && test1.User_Email == "test@mail.ru" && test1.User_BD == "01.10.2000" &&
//                is1.i == 1002 && is1.s == "Other" && Groups1.Count == 1 &&
//                group_field1.Id == 1002 && group_field1.Name == "Other" &&
//                field1.Name == "h" && type1.id == 1 && field1.Value == "yyy" &&
//                field1.UserCanEdit == true && field1.mandatory == true &&
//                fields1.Count == 1 && allgroupsTest.Count == 2
//                , warn);

//            Assert.IsTrue(allgroupsTest.ContainsKey(1000), warn);
//            allgroupsTest.TryGetValue(1000, out sss);
//            Assert.IsTrue(sss == "All Users", warn);

//            Assert.IsTrue(allgroupsTest.ContainsKey(1001), warn);
//            allgroupsTest.TryGetValue(1001, out sss);
//            Assert.IsTrue(sss == "Admins", warn);

//        }

//        [TestMethod]
//        public void UpdateOrAddUser_true_8_2()
//        {
//            string sss, warn = "incorrect result";

//            models.EditUser test1 = new EditUser();
//            test1.Id = 1100;
//            test1.User_Name = "testX";
//            test1.User_Email = "testX@mail.ru";
//            test1.User_BD = "01.10.2000";

//            List<IntString> Groups1 = new List<IntString>();
//            IntString is1 = new IntString();
//            is1.i = 1002;
//            is1.s = "Other";
//            Groups1.Add(is1);
//            test1.Groups = Groups1;

//            List<Group_Field> User_Fields1 = new List<Group_Field>();
//            Group_Field group_field1 = new Group_Field();
//            group_field1.Id = 1002;
//            group_field1.Name = "Other";
//            List<FieldModel> fields1 = new List<FieldModel>();
//            FieldModel field1 = new FieldModel();

//            field1.Name = "h";
//            FieldType type1 = new FieldType();


//            type1.id = 1;
//            field1.Value = "yyy";
//            field1.UserCanEdit = true;
//            field1.mandatory = true;

//            fields1.Add(field1);

//            group_field1.Fields = fields1;
//            User_Fields1.Add(group_field1);
//            test1.User_Fields = User_Fields1;

//            Dictionary<int, string> allgroupsTest = new Dictionary<int, string>();
//            allgroupsTest.Add(1000, "All Users");
//            allgroupsTest.Add(1001, "Admins");

//            test1.AllGroups = allgroupsTest;

//            UpdateOrAddUser(test1);

//            test1 = GetUserById(1100);

//            allgroupsTest = test1.AllGroups;

//            User_Fields1 = test1.User_Fields;
//            group_field1 = User_Fields1[0];
//            fields1 = group_field1.Fields;
//            field1 = fields1[0];

//            Groups1 = test1.Groups;
//            is1 = Groups1[0];

//            Assert.IsTrue(
//                test1.Id == 1001 && test1.User_Name == "testX" && test1.User_Email == "testX@mail.ru" && test1.User_BD == "01.10.2000" &&
//                is1.i == 1002 && is1.s == "Other" && Groups1.Count == 1 &&
//                group_field1.Id == 1002 && group_field1.Name == "Other" &&
//                field1.Name == "h" && type1.id == 1 && field1.Value == "yyy" &&
//                field1.UserCanEdit == true && field1.mandatory == true &&
//                fields1.Count == 1 && allgroupsTest.Count == 2
//                , warn);

//            Assert.IsTrue(allgroupsTest.ContainsKey(1000), warn);
//            allgroupsTest.TryGetValue(1000, out sss);
//            Assert.IsTrue(sss == "All Users", warn);

//            Assert.IsTrue(allgroupsTest.ContainsKey(1001), warn);
//            allgroupsTest.TryGetValue(1001, out sss);
//            Assert.IsTrue(sss == "Admins", warn);

//        }

//    }
//}
